package acwing_01;
import java.io.*;
import java.util.*;
public class _2816_双指针_判断子序列 {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int N = 100010;
	static int n;
	static int m;
	static int a[] = new int[N];
	static int b[] = new int[N];
	static StringTokenizer st;
	static boolean flag = false;
	public static void main(String[] args) throws IOException{
		st = new StringTokenizer(br.readLine());
		n = Integer.parseInt(st.nextToken());
		m = Integer.parseInt(st.nextToken());
		
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < m; i++) {
			b[i] = Integer.parseInt(st.nextToken());
		}
		
		// 如果b中含有子序列a
		for(int i = 0,j=0; i < m; i++) {
			// 题目中的子序列是按次序排的例如序列 {a1,a3,a5} 是序列 {a1,a2,a3,a4,a5}的一个子序列
			// 当前b的值等于a，说明找到子序列中一个相同的值，则a序列继续往下一个值
			if(b[i] == a[j]) {
				// 说明a序列的最后一个值也匹配到，说明有该子序列
				if(j == n - 1) {
					flag = true;
					break;
				}
				j++;
			}
		}
		
		if(flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
	}
}
